<template>
  <view class="page home">
    <home></home>
    <!-- <category v-if="currentIndex === 1"></category>
    <active v-if="currentIndex === 2"></active>
    <cart v-if="currentIndex === 3"></cart>
    <mine v-if="currentIndex === 4"></mine> -->
    <!-- <view class="tabBar">
      <view class="tabList flex-eve">
        <view v-for="(item, index) in tabBarList" :key="index" class="tab-item"
          :class="{ active: currentIndex === index }" @click="switchTab(index)">
          <template v-if="index === 2">
            <view class="tab_logo flex-center">
              <image class="wh-100" src="https://cdn.oss.bon-top.cn/static_bc/images/tabLogo.png"></image>
            </view>
          </template>
<template v-else>
            <image class="tab-icon" :src="getItemIcon(item, index)"></image>
            <text class="tab-text mt-12">{{ item.text }}</text>
          </template>
</view>
</view>
</view> -->
  </view>

  <!-- <GlobalToast ref="toastRef" /> -->


</template>
<script setup lang="js">
import { ref, onMounted } from 'vue';
import home from '../home/home.vue';
// import category from '../category/category.vue';
// import mine from '../mine/mine.vue';
// import active from '../active/active.vue';
// import cart from '../cart/cart.vue';
import { onLoad } from '@dcloudio/uni-app';
// import GlobalToast from '@/components/GlobalToast.vue'
// import { initToast } from '@/utils/utils.js'
// const toastRef = ref(null)
// const currentIndex = ref(0);
// onMounted(() => {

//   console.log('孤寡孤寡孤寡')
//   console.log('toastRef', toastRef)
//   // 初始化时注册Toast
//   initToast(toastRef.value)


// })
// const tabBarList = ref([
//   {
//     icon: '../../static/images/home.png',
//     activeIcon: '../../static/images/home_act.png',
//     text: '首页'
//   },
//   {
//     icon: '../../static/images/video.png',
//     activeIcon: '../../static/images/video_act.png',
//     text: '视频'
//   },
//   {
//     icon: '../../static/images/logo.png',
//     activeIcon: '../../static/images/logo.png',
//     text: ''
//   },
//   {
//     icon: '../../static/images/product.png',
//     activeIcon: '../../static/images/product_act.png',
//     text: '产品'
//   },
//   {
//     icon: '../../static/images/mine.png',
//     activeIcon: '../../static/images/mine_act.png',
//     text: '我的'
//   }
// ]);
// const getItemIcon = (item, index) => {
//   if (index === currentIndex.value) {
//     return item.activeIcon;
//   } else {
//     return item.icon;
//   }

// };

// const switchTab = (index) => {
//   currentIndex.value = index;

// };


// 自定义分享方法
const onCustomShare = () => {
  uni.share({
    provider: 'weixin', // 分享平台为微信
    scene: 'WXSceneSession', // 分享场景为会话
    title: '这是自定义分享的标题', // 分享标题
    path: '/pages/index/index', // 分享路径
    imageUrl: 'https://example.com/share-image.png', // 分享图片链接
    success() {
      console.log('分享成功');
    },
    fail(err) {
      console.error('分享失败', err);
    }
  });
}


//分享

// const onShareAppMessage=(res)=> {
//   return {
//     title: '白菜小程序 - 一起来抢白菜吧！', // 分享标题
//     path: '/pages/index/index', // 分享的路径
//     imageUrl: 'https://example.com/image.png', // 分享的图片
//     success: function(res) {
//       console.log('分享成功', res);
//     },
//     fail: function(err) {
//       console.error('分享失败', err);
//     }
//   };
// }

onLoad((options) => {
  // uni.showShareMenu({
  //   withShareTicket: true, // 是否使用带 shareTicket 的分享
  //   menus: ['shareAppMessage', 'shareTimeline'] // 显示分享按钮
  // });
  // console.log(options, "获取到的参数");
  // if (options.currentIndex) {
  //   currentIndex.value = Number(options.currentIndex)
  // }

})    
</script>

<style lang="scss" scoped>
.home {

  // height: 100%;
  .tabBar {
    position: fixed;
    z-index: 9999;
    bottom: 0;
    width: 100%;
    height: 166rpx;
    background: #f8f8f8;

    .tabList {
      width: 750rpx;
      height: 98rpx;
      background: #f8f8f8;
      border-radius: 4rpx 4rpx 4rpx 4rpx;

      // border: 2rpx solid red;
      .tab-item {
        width: 20%;
        height: 100%;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
      }

      .tab-icon {
        width: 48rpx;
        height: 48rpx;
      }

      .tab_logo {
        width: 100rpx;
        height: 72rpx;
        // background: #333333;
        border-radius: 40rpx 40rpx 40rpx 40rpx;
        font-family: 'DIN COROS';
        font-weight: 400;
        font-size: 38rpx;
        color: #dbf046;
      }

      .tab-text {
        font-weight: 800;
        font-size: 20rpx;
        color: #999999;
        line-height: 0rpx;
        text-align: left;
        font-style: normal;
        text-transform: none;
      }
    }
  }
}
</style>
